package cn.rocksolid.sport.common;

import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.annotation.IEnum;

import java.util.List;
import java.util.Set;

/**
 * Constants
 *
 * @author Axl Zhao
 * @email axl.zhao@163.com
 * @since 1.0.0 2016-11-15
 */
public class Constant {

  private Constant() {
  }

  public static final class TR {
    private TR() {
    }

    public static final TypeReference<List<String>> LIST_STRING = new TypeReference<List<String>>() {
    };
    public static final TypeReference<Set<String>> SET_STRING = new TypeReference<Set<String>>() {
    };
  }

  public static final class Symbol {
    private Symbol() {
    }

    public static final String EMPTY = "";
    public static final String SPACE = " ";
    public static final String DASH = "-";
    public static final String UNDER = "_";
    public static final String SLASH = "/";
    public static final String BACKSLASH = "\\";
    public static final String DOT = ".";
    public static final String COMMA = ",";
    public static final String SEMI = ";";
    public static final String COLON = ":";
  }

  /**
   * Error code reserved
   *
   * @author axl
   */
  public static final class ECR {

    private ECR() {
    }

    public static final String ERR_CODE_PATTERN = "E000000";
    public static final int SYS = 0;
    public static final int ACTIVITY = 20000;
    public static final int AGENCY = 30000;
    public static final int ASSIST = 40000;
    public static final int MEMBER = 50000;
    public static final int ORDER = 60000;
    public static final int SECURITY = 70000;
  }

  public static final class ShiroConst {
    private ShiroConst() {
    }

    /**
     * The salt of password which is used to HMAC-SHA256 processing password.
     */
    public static final int SALT_LEN = 32;
    public static final String SESSION_MANAGER_KEY = "sessionManager";
    public static final String SECURITY_MANAGER_KEY = "securityManager";
    public static final String FILTER_KEY = "shiroFilter";
    public static final String LIFECYCLE_BEAN_POST_PROCESSOR_KEY = "lifecycleBeanPostProcessor";
  }

  public static final class MQ {
    private MQ() {
    }

    public static final String CP = "Consumer";
    public static final String VTP = "VirtualTopic.";
    // For example: Consumer.BROKER_NAME.VirtualTopic.TOPIC_NAME, which is using on
    // the topic consumer.
    public static final String CONN_FACTORY_NAME = "ROCKSOLID_MQ_CONN_FACTORY";
    public static final String JMS_TEMPLATE_NAME = "ROCKSOLID_MQ_JMS_TEMPLATE";
    public static final String SUBSCRIBE_FACTORY = "ROCKSOLID_MQ_SUBSCRIBE_FACTORY";
    public static final String MSG_HEADER_CTX = "__rs_context";
    // Operation warning
    public static final String OP_SALE_EXP = VTP + "OP_SALE_EXP";
    // Pay
    public static final String PAY_CANCELED = VTP + "PAY_CANCELED";
    public static final String PAY_PENDING = VTP + "PAY_PENDING";
    public static final String PAY_FAILURE = VTP + "PAY_FAILURE";
    public static final String PAY_SUCCESS = VTP + "PAY_SUCCESS";
    public static final String REFUND_CANCELED = VTP + "REFUND_CANCELED";
    public static final String REFUND_PENDING = VTP + "REFUND_PENDING";
    public static final String REFUND_FAILURE = VTP + "REFUND_FAILURE";
    public static final String REFUND_SUCCESS = VTP + "REFUND_SUCCESS";
    // Order
    public static final String ORDER_CREATED = VTP + "ORDER_CREATED";
    public static final String ORDER_CANCELED = VTP + "ORDER_CANCELED";
    public static final String ORDER_BALANCE = VTP + "ORDER_BALANCE";
    public static final String ORDER_PAID = VTP + "ORDER_PAID";
    public static final String ORDER_CLOSED = VTP + "ORDER_CLOSED";
    // Deliver
    public static final String MERCHANDISE_DELIVERY = VTP + "MERCHANDISE_DELIVERY";
    public static final String MEMBERSHIP_DELIVERY = VTP + "MEMBERSHIP_DELIVERY";
    public static final String TOURNAMENT_DELIVERY = VTP + "TOURNAMENT_DELIVERY";
    public static final String TRAINING_DELIVERY = VTP + "TRAINING_DELIVERY";
    public static final String ACTIVITY_DELIVERY = VTP + "ACTIVITY_DELIVERY";
    public static final String SHOW_DELIVERY = VTP + "SHOW_DELIVERY";
    public static final String CERTIFICATION_DELIVERY = VTP + "CERTIFICATION_DELIVERY";
    public static final String FIELD_RESERVE_DELIVERY = VTP + "FIELD_RESERVE_DELIVERY";
    public static final String TICKET_DELIVERY = VTP + "TICKET_DELIVERY";
    public static final String DELIVER_RECEIPTION = VTP + "DELIVER_RECEIPTION";
    // Return
    public static final String VT_RETURN_RECEIPT = VTP + "RETURN.RECEIPT";
  }

  public static final class RockSolidHttpCorsProp {
    private RockSolidHttpCorsProp() {
    }

    public static final String VAL_SEPARATOR = ",";
    public static final String HDR_MAX_AGE = "Access-Control-Max-Age";
    public static final String HDR_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials";
    public static final String HDR_ALLOWED_HEADERS = "Access-Control-Allow-Headers";
    public static final String HDR_ALLOWED_ORIGIN = "Access-Control-Allow-Origin";
    public static final String HDR_ALLOWED_METHODS = "Access-Control-Allow-Methods";
  }

  public enum St implements IEnum<String> {
    /** 有效 */
    AVAILABLE,
    /** 过期 */
    EXPIRED,
    /** 无效 */
    DISABLED;

    @Override
    public String getValue() {
      return name();
    }
  }

  public enum AccessType implements IEnum<String> {
    /** The current access is Back office user */
    BACKOFFICE,
    /** The current access is notifier from third party */
    NOTIFIER,
    /** The current access is Agency user */
    AGENCY,
    /** The current access is Member user */
    MEMBER,
    /** The current access is bureau user */
    BUREAU;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  /**
   * Below are all of Enumeration types
   */

  public enum AppType implements IEnum<String> {
    /** Agency Web UI */
    AGENCY_WEBUI,
    /** Agency Mobile App */
    AGENCY_MOBILE,
    /** Agency Pad App */
    AGENCY_PAD,
    /** Member Web UI */
    MEMBER_WEBUI,
    /** Member Mobile App */
    MEMBER_MOBILE,
    /** Member Pad App */
    MEMBER_PAD,
    /** 微信小程序 */
    WECHAT_MP,
    /** 企业微信小程序 */
    WECHAT_2B_MP,
    /** 支付宝小程序 */
    ALIPAY_MP,
    /** 支付宝IOT小程序 */
    ALIPAY_IOT_MP,
    /** 京东小程序 */
    JD_MP,
    /** 百度小程序 */
    BAIDU_MP,
    /** 字节跳动小程序 */
    BYTE_DANCE_MP,
    /** QQ小程序 */
    QQ_MP,
    /** 钉钉小程序 */
    DINGDING_MP,
    /** 飞书小程序 */
    FEISHU_MP;

    @Override
    public String getValue() {
      return name();
    }
  }

  /**
   * Gender enumeration type
   *
   * @author Axl
   */
  public enum Gender implements IEnum<String> {
    /** Male */
    MALE,
    /** Female */
    FEMALE,
    /** Unknown */
    UNKNOWN;

    @Override
    public String getValue() {
      return name();
    }
  }

  /**
   * Invitation status
   */
  public enum Ist implements IEnum<String> {
    /** pending */
    PENDING,
    /** agreed */
    AGREED,
    /** denied */
    DISAGREED;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  /**
   * Purchasable type
   *
   * @author axl
   */
  public enum SaleType implements IEnum<String> {
    /**
     * This type can not be sale, ONLY for grouping product.
     */
    CATEGORY,
    /**
     * Common e-commerce product, which will be deliver and return under logistics
     * carrier
     */
    MERCHANDISE,
    /** Membership account of member */
    MEMBERSHIP,
    /** this type related with tournament registration */
    TOURNAMENT,
    /** this type related with tournament registration */
    TRAINING,
    /** this type related with tournament registration */
    ACTIVITY,
    /** this type related with tournament registration */
    SHOW,
    /** ability registration from baseball service */
    CERTIFICATION,
    /** field for reservation */
    FIELD_RESERVE,
    /** Ticket account of member */
    TICKET;

    @Override
    public String getValue() {
      return name();
    }
  }

  /**
   * saleable status
   *
   * @author axl
   */
  public enum Sst implements IEnum<String> {
    /** Sale */
    SALE,
    /** Offline */
    OFF;

    @Override
    public String getValue() {
      return name();
    }
  }

  /**
   * Membership account transaction
   *
   * @author Axl
   */
  public enum MsaTx implements IEnum<String> {
    /** Create account */
    CREATE,
    /** Renewal for account */
    RENEWAL,
    /** Leave */
    LEAVE,
    /** Resume */
    RESUME,
    /** Transfer */
    TRANSFER;

    @Override
    public String getValue() {
      return name();
    }
  }

  /**
   * Membership account status
   *
   * @author axl
   */
  public enum MsaSt implements IEnum<String> {
    /** Initialization status */
    NONE,
    /** Valid */
    VALID,
    /** Invalid */
    INVALID,
    /** Leaved */
    LEAVED;

    @Override
    public String getValue() {
      return name();
    }
  }

  /**
   * Transaction status
   *
   * @author axl
   */
  public enum TxSt implements IEnum<String> {
    /** 发起事务 */
    APPLY,
    /** 事务成功 */
    SUCCESS,
    /** 事务失败 */
    FAILURE,
    /** 事务超时 */
    TIMEOUT;

    @Override
    public String getValue() {
      return name();
    }
  }

  /**
   * 订单状态
   *
   * @author axl
   */
  public enum Ost implements IEnum<String> {
    /** Created */
    CREATED,
    /** Canceled */
    CANCELED,
    /** Balance */
    BALANCE,
    /** Paid */
    PAID,
    /** Closed */
    CLOSED;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  /**
   * Payment status
   *
   * @author axl
   */
  public enum PaySt implements IEnum<String> {
    /** Payment canceled */
    PAY_CANCELED,
    /** Pay done, waiting for gateway response */
    PAY_PENDING,
    /** Pay failure */
    PAY_FAILURE,
    /** Pay success */
    PAY_SUCCESS,
    /** Refund done, waiting for gateway response */
    REFUND_CANCELED,
    /** Refund done, waiting for gateway response */
    REFUND_PENDING,
    /** Refund failure */
    REFUND_FAILURE,
    /** Refund success */
    REFUND_SUCCESS;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  /**
   * Payment gateway transaction type
   *
   * @author axl
   */
  public enum PgTx implements IEnum<String> {
    /** PG = payment gateway, PG pre pay */
    PREPAY,
    /** PG cancel pay */
    CANCEL,
    /** Update client side pay */
    PAY,
    /** PG notify pay result */
    NOTIFY,
    /** PG refund */
    REFUND,
    /** PG refund notify */
    REFUND_NOTIFY,
    /** PG scan QR/2d codes payment */
    MICRO,
    /** Reverse payment from PG which is created by MICRO payment */
    REVERSE;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  /**
   * Payment gateway type
   *
   * @author axl
   */
  public enum PgType implements IEnum<String> {
    /** 微信 JSAPI */
    WECHAT,
    /** 支付宝 */
    ALI_PAY,
    /** 信用卡 */
    CREDIT_CARD,
    /** 借记卡 */
    DEBIT_CARD,
    /** 支票 */
    CHECK,
    /** 现金 */
    CASH;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum DeliverSt implements IEnum<String> {
    /** DELIVERED */
    DELIVERED,
    /** RECEIPT */
    RECEIPT,
    /** REJECTED */
    REJECTED;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum ReturnType implements IEnum<String> {
    /** DENY */
    DENY,
    /** FREE */
    FREE,
    /** FIXED */
    FIXED,
    /** RATE */
    RATE;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum ReturnSt implements IEnum<String> {
    /** RETURNED */
    RETURNED,
    /** RECEIPT */
    RECEIPT,
    /** REJECTED */
    REJECTED;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum LpSt implements IEnum<String> {
    /** 已下单 */
    ORDERED("O"),
    /** 待发货 */
    UNDERSTOCKOUT("U"),
    /** 已发货 */
    STOCKOUT("S"),
    /** 已揽件 */
    ACCEPT("C"),
    /** 运输中 */
    TRANSPORT("T"),
    /** 已派送 */
    DELIVERING("D"),
    /** 待取件 */
    PICKUPING("P"),
    /** 已签收 */
    RECEIVED("R"),
    /** 签收失败 */
    RECEIVED_FAILED("F");

    private final String value;

    private LpSt(String value) {
      this.value = value;
    }

    @Override
    public String getValue() {
      return this.value;
    }
  }

  /**
   * 菜单类型
   */
  public enum MenuType implements IEnum<String> {
    /** 目录 */
    CATALOG,
    /** 菜单 */
    MENU,
    /** 按钮 */
    BUTTON;

    @Override
    public String getValue() {
      return name();
    }
  }

  /**
   * Oss provider
   */
  public enum OssPt implements IEnum<String> {
    /** 七牛云 */
    QINIU,
    /** 阿里云 */
    ALIYUN,
    /** 腾讯云 */
    TENCENT,
    /** External service which means is direct reference an URL of file */
    EXTERNAL;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum IdCardVerifierType implements IEnum<String> {
    /** 阿里云 */
    ALIYUN;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  /**
   * Sms provider type
   */
  public enum SmsProviderType implements IEnum<String> {

    /** 阿里云 */
    ALIYUN;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  //  public enum Cst implements IEnum<String> {
  //    /** 有效 */
  //    AVAILABLE,
  //    /** 无效 */
  //    DISABLED;
  //
  //    @Override
  //    public String getValue() {
  //      return this.name();
  //    }
  //  }

  public enum Ast implements IEnum<String> {
    /** Initial */
    CREATED,
    /** Submit */
    SUBMITTED,
    /** Approved */
    APPROVED,
    /** Rejected */
    REJECTED;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum AbilityType implements IEnum<String> {
    /** Athlete */
    ATHLETE,
    /** Coach */
    COACH,
    /** Umpire */
    UMPIRE,
    /** Scorer */
    SCORER;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum GroupType implements IEnum<String> {
    /** gang */
    SQUAD,
    /** team */
    TEAM,
    /** family */
    FAMILY,
    /** school */
    SCHOOL,
    /** club */
    CLUB,
    /** company */
    COMPANY;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum GroupSt implements IEnum<String> {
    /** pending */
    PENDING,
    /** 有效 */
    AVAILABLE,
    /** 已解散 */
    DISBANDED,
    /** 过期 */
    EXPIRED,
    /** 无效 */
    DISABLED;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public static final class GmLv {
    private GmLv() {
    }

    /** group owner */
    public static final Integer OWNER = 999;
    /** group manager */
    public static final Integer MANAGER = 99;
    /** group crowd */
    public static final Integer CROWD = 9;
  }

  public enum Mst implements IEnum<String> {
    /** The member be invited who will be status available when first time login */
    INVITED,
    /** Normal member status */
    AVAILABLE,
    /** The member will not allow to login */
    BLOCKED;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum Pt implements IEnum<String> {
    /** created */
    ADULT,
    /** created */
    TEENAGE;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum Gt implements IEnum<String> {
    /** parent */
    PARENT,
    /** agent */
    AGENT;

    @Override
    public String getValue() {
      return this.name();
    }
  }
  //  /**
  //   * Auth relation type
  //   */
  //  public enum Art implements IEnum<String> {
  //    /** created */
  //    AGENT,
  //    /** created */
  //    BAN;
  //
  //    @Override
  //    public String getValue() {
  //      return this.name();
  //    }
  //  }
  //
  //  /**
  //   * Auth permission type
  //   */
  //  public enum Apt implements IEnum<String> {
  //    /** allowed all of activities for this relationship */
  //    ALL,
  //    /** allowed category of activities for this relationship */
  //    CATEGORY,
  //    /** allowed specified activity for this relationship */
  //    SPECIFIED;
  //
  //    @Override
  //    public String getValue() {
  //      return this.name();
  //    }
  //  }

  public enum EventSt implements IEnum<String> {
    /** Created just now */
    CREATED,
    /** Scheduled */
    SCHEDULED,
    /** Postpone */
    POSTPONE,
    /** Canceled */
    CANCELED,
    /** Finished */
    FINISHED;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum RegSt implements IEnum<String> {
    /** 报名 */
    REG,
    /** 请假 */
    QUIT,
    /** 待定 */
    TBD;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum AttendSt implements IEnum<String> {
    /** 出席 */
    ATTEND,
    /** 请假 */
    LEAVE,
    /** 迟到 */
    LATE,
    /** 缺席 */
    ABSENT;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum DepartSt implements IEnum<String> {
    /** 正常 */
    DEPART,
    /** 早退 */
    EARLY;

    @Override
    public String getValue() {
      return this.name();
    }
  }

  public enum FieldType implements IEnum<String> {
    /** Soccer field */
    SOCCER,
    /** Basketball field */
    BASKETBALL,
    /** Badminton field */
    BADMINTON;

    @Override
    public String getValue() {
      return this.name();
    }
  }
}
